/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.com.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author 839398
 */
@Entity
@Table(name = "tbl_persona")
@NamedQueries({
    @NamedQuery(name = "TblPersona.findAll", query = "SELECT t FROM TblPersona t"),
    @NamedQuery(name = "TblPersona.findByDocumento", query = "SELECT t FROM TblPersona t WHERE t.documento = :documento"),
    @NamedQuery(name = "TblPersona.findByNombre", query = "SELECT t FROM TblPersona t WHERE t.nombre = :nombre"),
    @NamedQuery(name = "TblPersona.findByApellido1", query = "SELECT t FROM TblPersona t WHERE t.apellido1 = :apellido1"),
    @NamedQuery(name = "TblPersona.findByApellido2", query = "SELECT t FROM TblPersona t WHERE t.apellido2 = :apellido2"),
    @NamedQuery(name = "TblPersona.findByEmail", query = "SELECT t FROM TblPersona t WHERE t.email = :email"),
    @NamedQuery(name = "TblPersona.findByTelefono", query = "SELECT t FROM TblPersona t WHERE t.telefono = :telefono"),
    @NamedQuery(name = "TblPersona.findByCelular", query = "SELECT t FROM TblPersona t WHERE t.celular = :celular"),
    @NamedQuery(name = "TblPersona.findByDireccion", query = "SELECT t FROM TblPersona t WHERE t.direccion = :direccion")})
public class TblPersona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "documento")
    private String documento;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "apellido1")
    private String apellido1;
    @Size(max = 15)
    @Column(name = "apellido2")
    private String apellido2;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 30)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "telefono")
    private long telefono;
    @Basic(optional = false)
    @NotNull
    @Column(name = "celular")
    private long celular;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "direccion")
    private String direccion;
    @OneToMany(mappedBy = "socioRefiere")
    private List<TblNatilleraPersona> tblNatilleraPersonaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblPersona")
    private List<TblNatilleraPersona> tblNatilleraPersonaList1;

    public TblPersona() {
    }

    public TblPersona(String documento) {
        this.documento = documento;
    }

    public TblPersona(String documento, String nombre, String apellido1, long telefono, long celular, String direccion) {
        this.documento = documento;
        this.nombre = nombre;
        this.apellido1 = apellido1;
        this.telefono = telefono;
        this.celular = celular;
        this.direccion = direccion;
    }

    public String getDocumento() {
        return documento;
    }

    public void setDocumento(String documento) {
        this.documento = documento;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido1() {
        return apellido1;
    }

    public void setApellido1(String apellido1) {
        this.apellido1 = apellido1;
    }

    public String getApellido2() {
        return apellido2;
    }

    public void setApellido2(String apellido2) {
        this.apellido2 = apellido2;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public long getTelefono() {
        return telefono;
    }

    public void setTelefono(long telefono) {
        this.telefono = telefono;
    }

    public long getCelular() {
        return celular;
    }

    public void setCelular(long celular) {
        this.celular = celular;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public List<TblNatilleraPersona> getTblNatilleraPersonaList() {
        return tblNatilleraPersonaList;
    }

    public void setTblNatilleraPersonaList(List<TblNatilleraPersona> tblNatilleraPersonaList) {
        this.tblNatilleraPersonaList = tblNatilleraPersonaList;
    }

    public List<TblNatilleraPersona> getTblNatilleraPersonaList1() {
        return tblNatilleraPersonaList1;
    }

    public void setTblNatilleraPersonaList1(List<TblNatilleraPersona> tblNatilleraPersonaList1) {
        this.tblNatilleraPersonaList1 = tblNatilleraPersonaList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (documento != null ? documento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblPersona)) {
            return false;
        }
        TblPersona other = (TblPersona) object;
        if ((this.documento == null && other.documento != null) || (this.documento != null && !this.documento.equals(other.documento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + documento;
    }
    
}
